package com.changgou.goods.dao;

import com.changgou.goods.pojo.Category;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CategoryMapper extends Mapper<Category> {

    /*
        根据一级分类的id查询对应的2分类属性以及3级分类属性
     */
    @Select("SELECT * FROM tb_category WHERE parent_id=#{id}")
////    @Select("SELECT * FROM tb_category WHERE parent_id IN (SELECT parent_id FROM tb_category WHERE id IN(SELECT id FROM tb_category WHERE parent_id=#{id}))")
    public List<Category> findListCategoryId(@Param("id") Integer id);

//    // 根据一级分类id查询对应的二级分类信息
//    @Select("SELECT id FROM tb_category WHERE parent_id=#{parent_id}")
//    public List<Category> findListCategoryFirst(@Param("parent_id") Integer parent_id);
//
//    //根据二级分类id查询对应的三级分类信息
//    @Select("SELECT parent_id FROM tb_category WHERE id=#{id}")
//    public List<Category> findListCategoryTwo(@Param("id") Integer id);
//
//    //根据三级分类id查询对应的信息
//    @Select("SELECT * FROM tb_category WHERE parent_id={parent_id}")
//    public List<Category> findListCategoryThree(@Param("parent_id") Integer parent_id);


}
